package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/09/15 23:49
 **/
public class Day13_5_Num538_ConvertBST {
    class Solution {
        int sum = 0;
        public TreeNode convertBST(TreeNode root) {
            dfs(root);
            return root;
        }
        private void dfs(TreeNode root){
            if(root == null) return;
            convertBST(root.right);
            root.val += sum;
            sum = root.val;
            convertBST(root.left);
        }
    }
}